var mongo = require('mongodb'),
  dbHost = '127.0.0.1',
  dbPort = 27017;

var Db = mongo.Db;
var Connection = mongo.Connection;
var Server = mongo.Server;
var db = new Db ('blog', new Server(dbHost, dbPort), {safe:true});

db.open(function(error, dbConnection){
  if (error) {
    console.error(error);
    process.exit(1);
  }
  console.log('db state: ', db._state);
  items = {
  "email":"hi@lemon.co",
  "admin":true,
  "password":"1"
  }
  /*dbConnection.collection('messages').insert(items, function(error, item){
    if (error) {
      console.error(error);
      process.exit(1);
    }
    console.info("created/inserted: ", item);
    db.close();
    process.exit(0);
  });*/
dbConnection.collection('users',function(error,collection){
	collection.insert(items, function(error, item){
	    if (error) {
	      console.error(error);
	      process.exit(1);
	    }
	    console.info("created/inserted: ", item);
	    db.close();
	    process.exit(0);
    });
  });
});